<template>
  <!-- 收入 合同统计-->
  <div v-auths="['contractCount']">
    <div class="topBox">
      <p class="name">收入</p>
      <p class="tip">数据截至：{{ date }} 00:00</p>
    </div>
    <div class="list">
      <!-- <div class="item">
        <img
          :src="require('/public/img/contract_icon1.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">合同总数</p>
          <p class="num">{{ countData.contractYearNum ?? 0 }}</p>
        </div>
      </div> -->
      <div class="item" style="background-color: rgba(255, 168, 70, 0.1)">
        <img
          :src="require('/public/img/contract_icon9.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">合同总额</p>
          <p class="num">{{ countData.contractYearMoney ?? 0 }}</p>
        </div>
      </div>
      <!-- <div class="item">
        <img
          :src="require('/public/img/contract_icon3.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">合同月新增</p>
          <p class="num">{{ countData.contractMonthNum ?? 0 }}</p>
        </div>
      </div> -->
      <div class="item" style="background-color: rgba(255, 209, 91, 0.1)">
        <img
          :src="require('/public/img/contract_icon4.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">合同月总额</p>
          <p class="num">{{ countData.contractMonthMoney ?? 0 }}</p>
        </div>
      </div>
      <div class="item" style="background-color: rgba(4, 184, 80, 0.1)">
        <img
          :src="require('/public/img/contract_icon5.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">客户总数</p>
          <p class="num">{{ countData.customerYearNum ?? 0 }}</p>
        </div>
      </div>
      <div class="item" style="background-color: rgba(250, 116, 107, 0.1)">
        <img
          :src="require('/public/img/contract_icon6.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">客户月新增</p>
          <p class="num">{{ countData.customerMonthNum ?? 0 }}</p>
        </div>
      </div>
      <div class="item" style="background-color: rgba(14, 70, 215, 0.1)">
        <img
          :src="require('/public/img/contract_icon7.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">应收总额</p>
          <p class="num">{{ countData.planCollectMoney ?? 0 }}</p>
        </div>
      </div>
      <div class="item" style="background-color: rgba(101, 110, 232, 0.1)">
        <img
          :src="require('/public/img/contract_icon8.webp')"
          alt=""
          class="img"
        />
        <div class="info">
          <p class="name">实收总额</p>
          <p class="num">
            {{ countData.customerPaymentMoney ?? 0 }} ({{
              countData.balanceMoney ?? 0
            }})
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "contractCount",
  title: "合同统计",
  icon: "el-icon-s-data",
  description: "合同统计信息展示",
  data () {
    return {
      countData: {},
      date: this.$TOOL.dateFormat(new Date(), "yyyy-MM-dd"),
    }
  },
  created () {
    this.getContractCountData()
  },
  methods: {
    async getContractCountData () {
      let { data } = await this.$API.contract.getContractCountData.get()
      this.countData = data
    },
  },
};
</script>

<style lang="scss" scoped>
.topBox {
  display: flex;
  align-items: baseline;
  margin-top: 20px;
  margin-bottom: 10px;
  .name {
    margin-right: 10px;
    font-weight: 600;
    font-size: 18px;
  }
  .tip {
    font-size: 14px;
    color: #999;
  }
}

.list {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 20px;
  overflow-x: auto;
}
.item {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-basis: calc(100% / 6);
  min-width: 220px;
  height: 110px;
  margin-right: 20px;
  border-radius: 4px;
  // border: 1px solid #e6e6e6;
  background: #fff;
  &:last-child {
    margin-right: 0;
  }
  .info {
    margin-left: 6px;
  }
  .img {
    transform: scale(0.8);
  }
  .name {
    white-space: nowrap;
    margin-bottom: 6px;
    font-size: 16px;
    color: #999;
  }
  .num {
    white-space: nowrap;
    font-weight: 600;
    font-size: 24px;
  }
}
</style>
